package com.linkage.jz.bankruptcy.activity.Project;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.linkage.jz.bankruptcy.BankruptcyApp;
import com.linkage.jz.bankruptcy.Consts;
import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.MainActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.AddProxyUserActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ZQUserDetailActivity;
import com.linkage.jz.bankruptcy.adapter.CommonTabPagerAdapter;
import com.linkage.jz.bankruptcy.bean.MyAddr;
import com.linkage.jz.bankruptcy.bean.MyProInfo;
import com.linkage.jz.bankruptcy.bean.MyProInfoAuth;
import com.linkage.jz.bankruptcy.bean.ObjValInfo;
import com.linkage.jz.bankruptcy.bean.ProManageInfo;
import com.linkage.jz.bankruptcy.bean.TaskAtta;
import com.linkage.jz.bankruptcy.bean.ZQUserDetailBaseInfo;
import com.linkage.jz.bankruptcy.fragment.Project.ProDetailFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProFlowFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProTaskFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProPublicFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProTalkFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProVoteFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProVoteZQFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProZQFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProZQZQFragment;
import com.linkage.jz.bankruptcy.net.BaseSubscriber;
import com.linkage.jz.bankruptcy.net.Network;
import com.linkage.jz.bankruptcy.net.ToastUtil;
//import com.linkage.jz.bankruptcy.widget.PublicPopupMenu;
//import com.linkage.jz.bankruptcy.widget.toprightmenu.TopMenuItem;
//import com.linkage.jz.bankruptcy.widget.toprightmenu.TopRightMenu;
import com.linkage.jz.bankruptcy.utils.SPUtils;
import com.linkage.jz.bankruptcy.widget.CreateZQUserDialog;
import com.linkage.jz.bankruptcy.widget.PopupMenuMainPro;
import com.linkage.jz.bankruptcy.widget.PopupMenuZQ;
import com.linkage.jz.bankruptcy.widget.PublicNoticeDialog;
import com.linkage.jz.bankruptcy.widget.ShapeLoadingDialog;
import com.linkage.jz.bankruptcy.widget.toprightmenu.TopMenuItem;
import com.linkage.jz.bankruptcy.widget.toprightmenu.TopRightMenu;
import com.linkage.seapeak.activity.chat.ChatDetailActivity;
import com.linkage.seapeak.activity.register.RegisterActivity;
import com.linkage.seapeak.activity.user.PermissionSettingActivity;
import com.linkage.seapeak.activity.vote.EditVoteMemberNoGroupActivity;
import com.linkage.seapeak.base.BaseActivity;
import com.linkage.seapeak.net.ResultCallBack;
import com.linkage.seapeak.pojo.ManagersInfo;
import com.linkage.seapeak.pojo.TempProject;
import com.linkage.seapeak.pojo.TempProjectDetail;
import com.linkage.seapeak.utils.CommonUtils;
import com.linkage.seapeak.utils.JsonUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jp.wasabeef.glide.transformations.CropCircleTransformation;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

import static com.linkage.jz.bankruptcy.BankruptcyApp.PROPERMISSION_G;
import static com.linkage.jz.bankruptcy.BankruptcyApp.PROPERMISSION_MANAGER;
import static com.linkage.jz.bankruptcy.BankruptcyApp.PROPERMISSION_ZQR;
import static com.linkage.seapeak.activity.user.PermissionSettingActivity.PERMISSIONSERTTING;


public class ProDetailActivity extends BaseActivity implements CommonTabPagerAdapter.TabPagerListener {
    private PublicNoticeDialog noticeDialog;
    Toolbar toolbar;
    CollapsingToolbarLayout collapsingToolbar;
    TabLayout tabLayout;
    AppBarLayout appbar;
    private ImageView moreBtn;
    private View top_muneimg;
    ViewPager viewpager;
    TextView tv_proname, tv_managename, tv_manageaddr,tv_contact,zq_team_count,zq_glr_count,zq_qt_count
            ,tv_managename_name,tv_managename_name_sp,tv_contact_name,tv_send_sms,tv_send_tel;//tv_manageuser;

    private String  focusId;
    ImageView iv_proimg;
    ArrayList arrays = new ArrayList();
    private CommonTabPagerAdapter adapter;
    private MyProInfo mInfo;
    protected ShapeLoadingDialog mShapeLoadingDialog;

    private Boolean FavreturnFlag = false;
    private  MenuItem menu_fav;
    public int dp2px(float dp) {
        return CommonUtils.dp2px(ProDetailActivity.this, dp);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
//        if (BankruptcyApp.isZQFlag) {
//            //getMenuInflater().inflate(R.menu.menu_zq_scrolling, menu);
//
//            getMenuInflater().inflate(R.menu.menu_project_detail_glr, menu);
//
//        } else {
//            //getMenuInflater().inflate(R.menu.menu_scrolling, menu);
//
//            getMenuInflater().inflate(R.menu.menu_project_detail_zqr, menu);
//        }
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        System.out.println("onPrepareOptionsMenu");
        menu.clear();
        if ("".equalsIgnoreCase(mInfo.getManagerId())) {
            //getMenuInflater().inflate(R.menu.menu_zq_scrolling, menu);

            if(FavreturnFlag)
            {
                getMenuInflater().inflate(R.menu.menu_project_detail_glr_fouse, menu);
            }else {

                getMenuInflater().inflate(R.menu.menu_project_detail_glr, menu);
            }

        } else {
            //getMenuInflater().inflate(R.menu.menu_scrolling, menu);
            if(mInfo.getAuth()== null )
            {
                return false;
            }
            if(!mInfo.getAuth().getPermissionSetting() && !mInfo.getAuth().getEditBasic())
            {
                return false;
            }

            getMenuInflater().inflate(R.menu.menu_project_detail_zqr, menu);
        }
        return super.onPrepareOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        //noinspection SimplifiableIfStatement
        if (id == R.id.toolbar_r_1) {
            if (BankruptcyApp.isZQFlag) {

            } else {
                CreateProjectDetailActivity.start(this, mInfo, 2);
            }
            return true;
        }
        if (id == R.id.toolbar_r_2) {
            PermissionSettingActivity.start(this, mInfo);
            return true;
        }

        if (id == R.id.menu_fav) {
//            ToastUtil.showShort("债权人页面，点击了右边菜单");

            String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
            if ("".equalsIgnoreCase(userToken)) {
                noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
                    @Override
                    public void onClick( View view ) {
                        switch (view.getId()) {
                            case R.id.ll_close:
                                noticeDialog.dismiss();
                                break;

                            case R.id.btn_chancel_notice:
                                noticeDialog.dismiss();

                                break;

                            case R.id.btn_save_notice:
                                RegisterActivity.start(ProDetailActivity.this);
                                noticeDialog.dismiss();
                                break;

                        }

                    }
                }, 1, "提示", "操作此功能，需要请您先注册/登录",
                        "取消", "确认");
                noticeDialog.show();
//                return;
            }else {
                if(FavreturnFlag)
                {
                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (v.getId() == R.id.btn_save_notice) {
                                DelFavPro();
                            }
                            noticeDialog.dismiss();
                        }
                    }, 1, "提示", "确认取消关注吗",
                            "取消", "确认");
                    noticeDialog.show();
                }else {
                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (v.getId() == R.id.btn_save_notice) {
                                FavPro();
                            }
                            noticeDialog.dismiss();
                        }
                    }, 1, "提示", "确认添加关注吗",
                            "取消", "确认");
                    noticeDialog.show();

                }
            }


            return true;
        } else if (id == R.id.menu_ddd) {


            if(mInfo.getAuth()== null )
            {
                return false;
            }
//            if(mInfo.getAuth().getEditBasic() && mInfo.getAuth().getPermissionSetting())
//            {
                PopupMenuMainPro popupMenu;
                popupMenu = new PopupMenuMainPro(this,mInfo.getAuth().getEditBasic(),mInfo.getAuth().getPermissionSetting());
                popupMenu.showLocation(R.id.menu_ddd);// 设置弹出菜单弹出的位置
                // 设置回调监听，获取点击事件
                popupMenu.setOnItemClickListener(new PopupMenuMainPro.OnItemClickListener() {

                    @Override
                    public void onClick(PopupMenuMainPro.MENUITEM item, String str) {
                        // TODO Auto-generated method stub
//                            changeType=1;
                        if(item == PopupMenuMainPro.MENUITEM.ITEM1) {
                            EditProjectDetailActivity.start(ProDetailActivity.this, mInfo, 2);
                        }else if(item == PopupMenuMainPro.MENUITEM.ITEM2)
                        {
                            PermissionSettingActivity.start(ProDetailActivity.this, mInfo);
                        }


                    }
                });
//            }else {
//                PopupMenuMainPro popupMenu;
//                popupMenu = new PopupMenuMainPro(this);
//                popupMenu.showLocation(R.id.menu_ddd);// 设置弹出菜单弹出的位置
//                // 设置回调监听，获取点击事件
//                popupMenu.setOnItemClickListener(new PopupMenuMainPro.OnItemClickListener() {
//
//                    @Override
//                    public void onClick(PopupMenuMainPro.MENUITEM item, String str) {
//                        // TODO Auto-generated method stub
////                            changeType=1;
//                        if(item == PopupMenuMainPro.MENUITEM.ITEM1) {
//                            EditProjectDetailActivity.start(ProDetailActivity.this, mInfo, 2);
//                        }else if(item == PopupMenuMainPro.MENUITEM.ITEM2)
//                        {
//                            PermissionSettingActivity.start(ProDetailActivity.this, mInfo);
//                        }
//
//
//                    }
//                });
//            }

            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            switch (v.getId()) {
                case R.id.ll_close:
                    noticeDialog.dismiss();
                    break;

                case R.id.btn_chancel_notice:
//                   Boolean flag =  noticelxDialog.cb_agree.isChecked();
                    noticeDialog.dismiss();

                    break;

                case R.id.btn_save_notice:
//                    finish();
                    FavPro();
                    noticeDialog.dismiss();
                    break;

            }
        }
    };

    private LinearLayout pro_detail_otherterm,ll_pro_detail_zq,pro_detail_managerterm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_project_detail);
        mShapeLoadingDialog = new ShapeLoadingDialog(this);
        EventBus.getDefault().register(this);
        String bookJson = getIntent().getStringExtra("info");
        mInfo = new Gson().fromJson(bookJson, MyProInfo.class);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout);
        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        appbar = (AppBarLayout) findViewById(R.id.appbar);
        viewpager = (ViewPager) findViewById(R.id.viewpager);
        top_muneimg = findViewById(R.id.top_muneimg);

        menu_fav = findViewById(R.id.menu_fav);
        tv_contact = findViewById(R.id.tv_contact);
        tv_proname = (TextView) findViewById(R.id.tv_proname);
        tv_managename = (TextView) findViewById(R.id.tv_managename);
        tv_manageaddr = (TextView) findViewById(R.id.tv_manageaddr);
//        tv_manageuser = (TextView) findViewById(R.id.tv_manageuser);
        iv_proimg = (ImageView) findViewById(R.id.iv_proimg);

        zq_team_count = findViewById(R.id.zq_team_count);
        zq_glr_count = findViewById(R.id.zq_glr_count);
        zq_qt_count = findViewById(R.id.zq_qt_count);
        tv_managename_name = findViewById(R.id.tv_managename_name);
        tv_managename_name_sp = findViewById(R.id.tv_managename_name_sp);
        tv_contact_name = findViewById(R.id.tv_contact_name);
        tv_send_sms = findViewById(R.id.tv_send_sms);
        tv_send_tel = findViewById(R.id.tv_send_tel);


        GetFavPro();

         pro_detail_managerterm = (LinearLayout) findViewById(R.id.pro_detail_managerterm);
        pro_detail_otherterm = (LinearLayout) findViewById(R.id.pro_detail_otherterm);

        ll_pro_detail_zq = (LinearLayout) findViewById(R.id.ll_pro_detail_zq);

        pro_detail_managerterm.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {


//                String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
//                if ("".equalsIgnoreCase(userToken)) {
//                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
//                        @Override
//                        public void onClick( View view ) {
//                            switch (view.getId()) {
//                                case R.id.ll_close:
//                                    noticeDialog.dismiss();
//                                    break;
//
//                                case R.id.btn_chancel_notice:
//                                    noticeDialog.dismiss();
//
//                                    break;
//
//                                case R.id.btn_save_notice:
//                                    RegisterActivity.start(ProDetailActivity.this);
//                                    noticeDialog.dismiss();
//                                    break;
//
//                            }
//
//                        }
//                    }, 1, "提示", "操作此功能，需要请您先注册/登录",
//                            "取消", "确认");
//                    noticeDialog.show();
//                    return;
//                }else {
                    if(mInfo.getAuth()!=null)
                    {
                        if(mInfo.getAuth().getOpenCreditorsList())
                            ZQUserListActivity.start(ProDetailActivity.this, mInfo);
                    }

//                }


            }
        });


//        pro_detail_managerterm = (LinearLayout) findViewById(R.id.pro_detail_managerterm);

        pro_detail_otherterm.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
//                if(!"".equalsIgnoreCase(mInfo.getOth))

//                String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
//                if ("".equalsIgnoreCase(userToken)) {
//                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
//                        @Override
//                        public void onClick( View view ) {
//                            switch (view.getId()) {
//                                case R.id.ll_close:
//                                    noticeDialog.dismiss();
//                                    break;
//
//                                case R.id.btn_chancel_notice:
//                                    noticeDialog.dismiss();
//
//                                    break;
//
//                                case R.id.btn_save_notice:
//                                    RegisterActivity.start(ProDetailActivity.this);
//                                    noticeDialog.dismiss();
//                                    break;
//
//                            }
//
//                        }
//                    }, 1, "提示", "操作此功能，需要请您先注册/登录",
//                            "取消", "确认");
//                    noticeDialog.show();
//                    return;
//                }else {
                    if(mInfo.getAuth()!=null)
                    {
                        if(mInfo.getAuth().getOpenOtherList())
                            OtherUserListActivity.start(ProDetailActivity.this, mInfo);
                    }

//                }



            }
        });



//        LinearLayout ll_pro_detail_zq = (LinearLayout) findViewById(R.id.ll_pro_detail_zq);
        ll_pro_detail_zq.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {


//                String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
//                if ("".equalsIgnoreCase(userToken)) {
//                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
//                        @Override
//                        public void onClick( View view ) {
//                            switch (view.getId()) {
//                                case R.id.ll_close:
//                                    noticeDialog.dismiss();
//                                    break;
//
//                                case R.id.btn_chancel_notice:
//                                    noticeDialog.dismiss();
//
//                                    break;
//
//                                case R.id.btn_save_notice:
//                                    RegisterActivity.start(ProDetailActivity.this);
//                                    noticeDialog.dismiss();
//                                    break;
//
//                            }
//
//                        }
//                    }, 1, "提示", "操作此功能，需要请您先注册/登录",
//                            "取消", "确认");
//                    noticeDialog.show();
//                    return;
//                }else {
                    if(mInfo.getAuth()!=null)
                    {
                        if(mInfo.getAuth().getOpenAdministratorList())
                            ManagerListActivity.start(ProDetailActivity.this, mInfo);
                    }

//                }
            }
        });


        //2.MODE_FIXED模式
//        tabLayout.setTabMode(TabLayout.MODE_FIXED);

        setToolBarReplaceActionBar();
        setTitleToCollapsingToolbarLayout();
        initViews();
        getData();
        getDetailInfo();
    }

    public void showLoading() {
//        mShapeLoadingDialog.setLoadingText("提交信息中...");
//        mShapeLoadingDialog.setCanceledOnTouchOutside(false);
//        mShapeLoadingDialog.show();
//        new Handler().postDelayed(new Runnable() {
//            public void run() {
//                mShapeLoadingDialog.dismiss();
//            }
//        }, 800);
    }
    /**
     * 用toolBar替换ActionBar
     */
    private void setToolBarReplaceActionBar() {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();//结束程序
            }
        });
    }

    /**
     * 使用CollapsingToolbarLayout必须把title设置到CollapsingToolbarLayout上，
     * 设置到Toolbar上则不会显示
     */
    private void setTitleToCollapsingToolbarLayout() {
        final LinearLayout headLayout = findViewById(R.id.head_layout);
        collapsingToolbar.setCollapsedTitleGravity(Gravity.LEFT);//设置收缩后标题的位置
        collapsingToolbar.setExpandedTitleGravity(Gravity.CENTER);////设置展开后标题的位置
        //使用下面两个CollapsingToolbarLayout的方法设置展开透明->折叠时你想要的颜色
        collapsingToolbar.setExpandedTitleColor(getResources().getColor(android.R.color.transparent));
        collapsingToolbar.setCollapsedTitleTextColor(getResources().getColor(R.color.black));
        appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                if (verticalOffset <= -headLayout.getHeight() / 2) {
                    collapsingToolbar.setTitle(mInfo.getProjectName());
                } else {
                    collapsingToolbar.setTitle("");
                }
            }
        });
    }

    public void initViews() {
        if (mInfo != null) {
            String str = mInfo.getPublicSection();
            if (!"".equalsIgnoreCase(mInfo.getOtherMemberId())) {
                if ("PROJECTGUEST".equalsIgnoreCase(mInfo.getOtherMemberRole())) {
                    BankruptcyApp.curProPermission = 20;
                } else if ("JUDGE".equalsIgnoreCase(mInfo.getOtherMemberRole())) {
                    BankruptcyApp.curProPermission = 21;
                } else if ("CONTRIBUTOR".equalsIgnoreCase(mInfo.getOtherMemberRole())) {
                    BankruptcyApp.curProPermission = 22;
                } else if ("STAFF".equalsIgnoreCase(mInfo.getOtherMemberRole())) {
                    BankruptcyApp.curProPermission = 23;
                } else {
                    BankruptcyApp.curProPermission = 20;
                }

                 BankruptcyApp.isZQFlag = false;
                String tmp = JsonUtil.bean2json(mInfo.getOtherMember());
                String tmp1 = JsonUtil.object2json(mInfo.getOtherMember());
                if(!"".equalsIgnoreCase(tmp) ) {

                    try {
                        Gson gson = new Gson();
                        JSONObject obj = new JSONObject(tmp1);

                        ProManageInfo otherInfo = gson.fromJson(obj.toString(), ProManageInfo.class);

                        if (otherInfo != null)
                            str = otherInfo.getProjectColumnPermission();
                    }catch ( Exception ex)
                    {
                        ex.printStackTrace();
                    }
                }
            } else if (!"".equalsIgnoreCase(mInfo.getCreditorId())) {

                BankruptcyApp.curProPermission = 10;
                BankruptcyApp.isZQFlag = true;
                str = mInfo.getPublicSection();

            } else {


                if(!"".equalsIgnoreCase((String)mInfo.getManagerId())) {
                    BankruptcyApp.curProPermission = PROPERMISSION_MANAGER;
                    BankruptcyApp.isZQFlag = false;

                    String tmp = JsonUtil.bean2json(mInfo.getManager());
                    String tmp1 = JsonUtil.object2json(mInfo.getManager());
                    if(!"".equalsIgnoreCase(tmp) ) {

                        try {
                            Gson gson = new Gson();
                            JSONObject obj = new JSONObject(tmp1);

                            ProManageInfo otherInfo = gson.fromJson(obj.toString(), ProManageInfo.class);

                            if (otherInfo != null)
                                str = otherInfo.getProjectColumnPermission();
                        }catch ( Exception ex)
                        {
                            ex.printStackTrace();
                        }
                    }
                }else {
                    BankruptcyApp.curProPermission = PROPERMISSION_G;
                    BankruptcyApp.isZQFlag = true;
                    str = mInfo.getPublicSection();
                }
            }

            supportInvalidateOptionsMenu();



            if(mInfo.getAuth()!= null) {

//                mInfo.getAuth().setOpenCreditorsList(true);
//                mInfo.getAuth().setOpenAdministratorList(true);
//                mInfo.getAuth().setOpenOtherList(false);
                if (mInfo.getAuth().getOpenCreditorsList()) {
                    pro_detail_managerterm.setVisibility(View.VISIBLE);
                } else {
                    pro_detail_managerterm.setVisibility(View.GONE);
                }
                if (mInfo.getAuth().getOpenAdministratorList()) {
                    ll_pro_detail_zq.setVisibility(View.VISIBLE);
                } else {
                    ll_pro_detail_zq.setVisibility(View.GONE);
                }
                if (mInfo.getAuth().getOpenOtherList()) {
                    pro_detail_otherterm.setVisibility(View.VISIBLE);
                } else {
                    pro_detail_otherterm.setVisibility(View.GONE);
                }
            }
            tv_proname.setText(mInfo.getProjectName());
            //TODO 这个地方设置页面内容


            if("".equalsIgnoreCase(mInfo.getContacts()) ||"null".equalsIgnoreCase(mInfo.getContacts()))
            {
                tv_contact.setVisibility(View.GONE);

                tv_contact_name.setVisibility(View.GONE);
            }else{
                tv_contact.setText(mInfo.getContacts());
            }




            if(mInfo.getManagersList()==null || mInfo.getManagersList().size() <1)
            {
                tv_managename.setVisibility(View.GONE);
                tv_managename_name.setVisibility(View.GONE);
                tv_managename_name_sp.setVisibility(View.GONE);
                tv_manageaddr.setVisibility(View.GONE);
            }else{
                tv_managename.setVisibility(View.GONE);
                tv_managename_name.setVisibility(View.GONE);
                tv_managename_name_sp.setVisibility(View.GONE);
                String manageaddr_l  = "";
                String manageaddr_r1  = "";
                int manageaddr_count = 0;


                for(int i=0;i<mInfo.getManagersList().size();i++)
                {
                    ManagersInfo info = mInfo.getManagersList().get(i);
                    if(info.getMaster())
                    {
                        tv_managename.setVisibility(View.VISIBLE);
                        tv_managename_name.setVisibility(View.VISIBLE);
                        tv_managename_name_sp.setVisibility(View.VISIBLE);
                        tv_manageaddr.setVisibility(View.VISIBLE);
                        tv_managename.setText(info.getManagersAdministrator());
                        if("0".equalsIgnoreCase(info.getManagersType())) {
                            manageaddr_l = info.getManagersAdministrator();
                        } else {
                            manageaddr_l = info.getManagersName();

                        }

                    }else{
                        if(manageaddr_count == 0) {
                            manageaddr_count++;
                            if ("0".equalsIgnoreCase(info.getManagersType())) {
                                manageaddr_r1 = info.getManagersAdministrator();
                            } else {
                                manageaddr_r1 = info.getManagersName();

                            }

                        }

                    }

                }

                if(!"".equalsIgnoreCase(manageaddr_r1))
                {
                    manageaddr_l =   manageaddr_l +" | " +manageaddr_r1;
                    if(mInfo.getManagersList().size()>2)
                    {
                        manageaddr_l = manageaddr_l+"...";
                    }
                }
                tv_manageaddr.setText(manageaddr_l);
            }


//            tv_managename.setText
//            tv_contact.setText("这个地方是联系人");
//            tv_managename.setText("这里是负责人");
//            tv_manageaddr.setText("这个地方是地址");

            zq_team_count.setText(mInfo.getCreditorNum());
            zq_glr_count.setText(mInfo.getManagersTeamNum());
            zq_qt_count.setText(mInfo.getOtherMemberNum());
//            tv_manageuser.setText(mInfo.getDebtorLegalRepresentative());

            //contactPhone  站内信sendSysUserId   聊天对象名称contacts
            String mUserid = mInfo.getSendSysUserId();
            String mUsername = mInfo.getContacts();
            final String phone = mInfo.getContactPhone();
            tv_send_sms.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
                    if ("".equalsIgnoreCase(userToken)) {
                        noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick( View view ) {
                                switch (view.getId()) {
                                    case R.id.ll_close:
                                        noticeDialog.dismiss();
                                        break;

                                    case R.id.btn_chancel_notice:
                                        noticeDialog.dismiss();

                                        break;

                                    case R.id.btn_save_notice:
                                        RegisterActivity.start(ProDetailActivity.this);
                                        noticeDialog.dismiss();
                                        break;

                                }

                            }
                        }, 1, "提示", "操作此功能，需要请您先注册/登录",
                                "取消", "确认");
                        noticeDialog.show();
                        return;
                    }else {
                        if(!"".equalsIgnoreCase(mUserid)) {
                            ChatDetailActivity.start(ProDetailActivity.this, mUserid,
                                    mUsername, mInfo.getId());
                        }else{
                            showToast("未有相关联系人", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                        }

                    }


                }
            });
            SetPhone(phone);
//            final String  phone_tmp = phone;
            tv_send_tel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                     if("".equalsIgnoreCase(phone)){
                         showToast("未有相关联系人", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                    return;
                }
                    noticeDialog = new PublicNoticeDialog(ProDetailActivity.this, new View.OnClickListener(){

                        @Override
                        public void onClick(View v) {
                            switch (v.getId()) {
                                case R.id.ll_close:
                                    noticeDialog.dismiss();
                                    break;
                                case R.id.btn_chancel_notice:

                                        if(checkReadPermission(Manifest.permission.CALL_PHONE,REQUEST_SMS_PERMISSION)){

                                            try {
//                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone));

                                                Intent intent = new Intent(Intent.ACTION_SENDTO);
                                                Uri data = Uri.parse("smsto:" + phone);
                                                intent.setData(data);
                                                startActivity(intent);

//                                                Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:"+phoneNumber));
//                                                intent.putExtra("sms_body", message);
//                                                startActivity(intent);

                                            }catch (Exception ex){
                                                ex.printStackTrace();
                                            }
                                        }
                                    noticeDialog.dismiss();
                                        break;

                                case R.id.btn_save_notice:
                                    if(!"".equalsIgnoreCase(phone)) {
                                        if(checkReadPermission(Manifest.permission.CALL_PHONE,REQUEST_CALL_PERMISSION)){

                                            try {
//                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone));

                                                Intent intent = new Intent(Intent.ACTION_CALL);
                                                Uri data = Uri.parse("tel:" + phone);
                                                intent.setData(data);
                                                startActivity(intent);
                                            }catch (Exception ex){
                                                ex.printStackTrace();
                                            }
                                        }
                                    }else{
                                        showToast("未有相关联系人", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                                    }
                                    noticeDialog.dismiss();

                                    break;
                            }
                        }
                    }, 2,phone, phone,"发短信","拨打电话");
                    noticeDialog.show();
                }
            });


            String url = mInfo.getProjectLogo();

            Glide.with(this).load(url).placeholder(R.drawable.ic_launcher).into(iv_proimg);


            String[] parts = str.split(",");

            Map<String,String> redPointMap = new HashMap<>();
            arrays.clear();

            if (mInfo.getAuth().getProjectColumnList() != null ) {
                for (int i = 0; i < mInfo.getAuth().getProjectColumnList().size(); i++) {
                    ObjValInfo info = mInfo.getAuth().getProjectColumnList().get(i);
                    if (info != null) {
                        if ("概况".equalsIgnoreCase(info.getText())) {
                            arrays.add("概况");
                            redPointMap.put("概况",info.getNum());
                        }
                        if ("进度".equalsIgnoreCase(info.getText())) {
                            arrays.add("进度");
                            redPointMap.put("进度",info.getNum());
                        }
                        if ("债权".equalsIgnoreCase(info.getText())) {
                            arrays.add("债权");
                            redPointMap.put("债权",info.getNum());
                        }
                        if ("讨论".equalsIgnoreCase(info.getText())) {
                            arrays.add("讨论");
                            redPointMap.put("讨论",info.getNum());
                        }
                        if ("表决".equalsIgnoreCase(info.getText())) {
                            arrays.add("表决");
                            redPointMap.put("表决",info.getNum());
                        }
                        if ("任务".equalsIgnoreCase(info.getText())) {
                            arrays.add("任务");
                            redPointMap.put("任务",info.getNum());
                        }
                        if ("公示".equalsIgnoreCase(info.getText())) {
                            arrays.add("公示");
                            redPointMap.put("公示",info.getNum());
                        }
                    }
                }
            }
//            if ("".equalsIgnoreCase(str)) {
//                arrays.add("概况");
//            } else {
//
//                for (int i = 0; i < parts.length; i++) {
//                    if ("0".equalsIgnoreCase(parts[i])) {
//                        arrays.add("概况");
//                    }
//                    if ("1".equalsIgnoreCase(parts[i])) {
//                        arrays.add("进度");
//                    }
//                    if ("2".equalsIgnoreCase(parts[i])) {
//                        arrays.add("债权");
//                    }
//                    if ("3".equalsIgnoreCase(parts[i])) {
//                        arrays.add("表决");
//                    }
//                    if ("4".equalsIgnoreCase(parts[i])) {
//                        arrays.add("讨论");
//                    }
//                    if ("5".equalsIgnoreCase(parts[i])) {
//                        if (!BankruptcyApp.isZQFlag) {
//                            arrays.add("任务");
//                        }
//                    }
//                    if ("6".equalsIgnoreCase(parts[i])) {
//                        arrays.add("公示");
//                    }
//
//                }
//            }
            if (arrays.size() == 0) {
                arrays.add("概况");
            }

            //for test
//            arrays.clear();
//            arrays.add("概况");
//            arrays.add("进度");
////            arrays.add("表决");
//            arrays.add("债权");
            //test end
            adapter = new CommonTabPagerAdapter(getSupportFragmentManager()
                    , arrays.size(), arrays, this);
            adapter.setListener(this);
            viewpager.setAdapter(adapter);
            tabLayout.setupWithViewPager(viewpager);

            if(arrays.size()>3)
            {
                tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
            }else{
                tabLayout.setTabMode(TabLayout.MODE_FIXED);
            }
            for (int i = 0; i <tabLayout.getTabCount() ; i++) {
                tabLayout.getTabAt(i).setCustomView(R.layout.custom_tab_pro) ;
            }
            for (int i = 0; i <tabLayout.getTabCount() ; i++) {
                TextView tv_text = tabLayout.getTabAt(i).getCustomView().findViewById(R.id.text);
                TextView tv_num = tabLayout.getTabAt(i).getCustomView().findViewById(R.id.num);
                tv_text.setText((CharSequence) arrays.get(i));
                if(i==0){
                    tv_text.setTextColor(Color.parseColor("#289F9F"));
                }
                if("0".equals(redPointMap.get( arrays.get(i)))){
                    tv_num.setVisibility(View.GONE);
                }else {
                    tv_num.setVisibility(View.VISIBLE);
                    tv_num.setText(redPointMap.get(arrays.get(i)));
                }
            }
            tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                @Override
                public void onTabSelected(TabLayout.Tab tab) {
                    TextView txt =  ((TextView)tab.getCustomView().findViewById(R.id.text));
                    if(txt!=null) {
                        ((TextView) tab.getCustomView().findViewById(R.id.text)).setTextColor(Color.parseColor("#289F9F"));
                    }
                }

                @Override
                public void onTabUnselected(TabLayout.Tab tab) {
                    TextView txt =  ((TextView)tab.getCustomView().findViewById(R.id.text));
                    if(txt!=null) {
                        ((TextView) tab.getCustomView().findViewById(R.id.text)).setTextColor(Color.parseColor("#151515"));
                    }
                }

                @Override
                public void onTabReselected(TabLayout.Tab tab) {

                }
            });
//            viewpager.setCurrentItem(2);
        }
    }



    @Override
    protected void onResume() {
        super.onResume();
        getDetailInfo();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        //在界面销毁的地方要解绑
        EventBus.getDefault().unregister(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == PERMISSIONSERTTING && resultCode == RESULT_OK) {
//            修改权限后获取项目数据
            getDetailInfo();
        }
        (getFragment(viewpager.getCurrentItem())).onActivityResult(requestCode, resultCode, data);
    }


    @Subscribe
    public void getEventBus(MyProInfo info1) {
        if (info1 != null) {
            mInfo = info1;
            adapter.notifyDataSetChanged();
            if (mInfo != null) {
                tv_proname.setText(mInfo.getProjectName());
                if(mInfo.getManagersList()==null || mInfo.getManagersList().size() <1)
                {
                    tv_managename.setVisibility(View.GONE);
                    tv_managename_name.setVisibility(View.GONE);
                    tv_managename_name_sp.setVisibility(View.GONE);
                    tv_manageaddr.setVisibility(View.GONE);
                }else{
                    tv_managename.setVisibility(View.GONE);
                    tv_managename_name.setVisibility(View.GONE);
                    tv_managename_name_sp.setVisibility(View.GONE);
                    String manageaddr_l  = "";
                    String manageaddr_r1  = "";
                    int manageaddr_count = 0;


                    for(int i=0;i<mInfo.getManagersList().size();i++)
                    {
                        ManagersInfo info = mInfo.getManagersList().get(i);
                        if(info.getMaster())
                        {
                            tv_managename.setVisibility(View.VISIBLE);
                            tv_managename_name.setVisibility(View.VISIBLE);
                            tv_managename_name_sp.setVisibility(View.VISIBLE);
                            tv_manageaddr.setVisibility(View.VISIBLE);
                            tv_managename.setText(info.getManagersName());
                            if("0".equalsIgnoreCase(info.getManagersType()))
                            {
                                manageaddr_l = info.getManagersName();
                            }else{
                                manageaddr_l = info.getManagersAdministrator();
                            }

                        }else{
                            if(manageaddr_count == 0) {
                                manageaddr_count++;
                                if ("0".equalsIgnoreCase(info.getManagersType())) {
                                    manageaddr_r1 = info.getManagersName();
                                } else {
                                    manageaddr_r1 = info.getManagersAdministrator();
                                }
                            }
//                            break;
                        }

                    }

                    if(!"".equalsIgnoreCase(manageaddr_r1))
                    {
                        manageaddr_l =   manageaddr_l +" | " +manageaddr_r1;
                        if(mInfo.getManagersList().size()>2)
                        {
                            manageaddr_l = manageaddr_l+"...";
                        }
                    }
                    tv_manageaddr.setText(manageaddr_l);
                }
//                tv_manageuser.setText(mInfo.getDebtorLegalRepresentative());

                String url = mInfo.getProjectLogo();

                Glide.with(this).load(url)
                        .bitmapTransform(new CropCircleTransformation(this))
                        .placeholder(R.drawable.avatar_defult)
                        .into(iv_proimg);
            }
            //这里拿到事件之后吐司一下
            //            Toast.makeText(getActivity(), "num" + num, Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public Fragment getFragment(int position) {

        String str = (String) arrays.get(position);
        if ("概况".equalsIgnoreCase(str)) {
            //管理人、债权人共用页面
            return ProDetailFragment.newInstance(position, mInfo);
        } else if ("进度".equalsIgnoreCase(str)) {
            return ProFlowFragment.newInstance(position, mInfo.getId());
        } else if ("债权".equalsIgnoreCase(str)) {
            if (BankruptcyApp.curProPermission == 0) {
                //管理人页面
                return ProZQFragment.newInstance(position, mInfo.getId(), mInfo);
            } else if (BankruptcyApp.curProPermission == 10) {
                //债权人页面
                return ProZQZQFragment.newInstance(position, mInfo.getId(), mInfo);
            } else if (BankruptcyApp.curProPermission == 20 || BankruptcyApp.curProPermission == 21 || BankruptcyApp.curProPermission == 22 || BankruptcyApp.curProPermission == 23)
            {
                return ProZQFragment.newInstance(position, mInfo.getId(), mInfo);
            } else {
                //其他人员页面
                return ProZQFragment.newInstance(position, mInfo.getId(), mInfo);
            }
        } else if ("表决".equalsIgnoreCase(str)) {
            if (BankruptcyApp.curProPermission == 0) {
                //管理人页面

                return ProVoteFragment.newInstance(position, mInfo.getId(), mInfo.getProjectType());
            } else {
                //其他人员页面

                String creditorId =  mInfo.getCreditorId();
                if("".equalsIgnoreCase(creditorId) && !"".equalsIgnoreCase(mInfo.getOtherMemberId()))
                {
                    creditorId = mInfo.getOtherMemberId();
                }
                return ProVoteZQFragment.newInstance(position, mInfo.getId(),creditorId);
            }
        } else if ("讨论".equalsIgnoreCase(str)) {
            return ProTalkFragment.newInstance(position, mInfo.getId());
        } else if ("任务".equalsIgnoreCase(str)) {
            return ProTaskFragment.newInstance(position, mInfo.getId());
        } else if ("公示".equalsIgnoreCase(str)) {
            return ProPublicFragment.newInstance(position, mInfo.getId());
        } else {

            return ProDetailFragment.newInstance(position, mInfo);

        }
    }

    public void getData() {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .getProjectDetailInfo(userToken, mInfo.getId())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
//                            super.onNext(json);
                            return;
                        }
                        JsonObject datajson = json.getAsJsonObject("data")
                                .getAsJsonObject();
                        String strdata = datajson.toString();
                        TempProjectDetail proInfo = new Gson().fromJson(strdata, TempProjectDetail.class);
                        mInfo.setPublicSection(proInfo.projectInfo.getPublicSection());
                        mInfo.setManagersList(proInfo.managersList);
                        if(proInfo.projectInfo.getContacts() == null) {
                            mInfo.setContacts("");
                        }else{
                            mInfo.setContacts(proInfo.projectInfo.getContacts());
                        }
                        mInfo.setContactPhone(proInfo.projectInfo.getContactPhone());
//                        initViews();
//                        JsonObject data = json.getAsJsonObject("data");
//                        JsonArray arr1 = data.getAsJsonArray("attachmentSLWSList");
//                        JsonArray arr2 = data.getAsJsonArray("attachmentGLSWSList");
//                        JsonArray arr3 = data.getAsJsonArray("attachmentOtherList");
//                        mInfo.getCourtSlwsFileList().addAll(TaskAtta.parse(arr1));
//                        mInfo.getCourtManagerFileList().addAll(TaskAtta.parse(arr2));
//                        mInfo.getOtherFileList().addAll(TaskAtta.parse(arr3));
//                        mAdapter.notifyDataSetChanged();
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                    }
                });
    }
    private void getDetailInfo() {
        showProgress();
        Network.getAPIService()
                .getDetailInfo(BankruptcyApp.userToken, mInfo.getId())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            return;
                        } else {
                            try {
                                TempProject tempProject = new Gson().fromJson(json.getAsJsonObject("data")
                                        .toString(), TempProject.class);
                                //少了用户身份
                                MyProInfoAuth auth =  new Gson().fromJson(json.getAsJsonObject("data")
                                        .getAsJsonObject("auth").toString(), MyProInfoAuth.class);

                                MyProInfo myInfo = new MyProInfo();
                                myInfo = tempProject.turnData(myInfo);
                                mInfo.setPublicStatus(myInfo.getPublicStatus());
                                mInfo.setPublicSection(myInfo.getPublicSection());
                                mInfo.setClose(myInfo.getClose());
                                mInfo.setAllowJoin(myInfo.getAllowJoin());
                                mInfo.setCloseClaimFiling(myInfo.getCloseClaimFiling());
                                mInfo.setOpenDiscussion(myInfo.getOpenDiscussion());
                                mInfo.setAllowCreditorsChangInfo(myInfo.getAllowCreditorsChangInfo());
                                mInfo.setDisplayedInstantly(myInfo.getDisplayedInstantly());
                                mInfo.setCreditorsVisibleDetails(myInfo.getCreditorsVisibleDetails());
                                mInfo.setOpenCreditorsList(myInfo.getOpenCreditorsList());
                                mInfo.setOpenCreditorsInfo(myInfo.getOpenCreditorsInfo());
                                mInfo.setOpenAdministratorList(myInfo.getOpenAdministratorList());
                                mInfo.setOpenAdministratorInfo(myInfo.getOpenAdministratorInfo());
                                mInfo.setSmsScope(myInfo.getSmsScope());
                                mInfo.setClose(myInfo.getClose());
                                mInfo.setManagersList(myInfo.getManagersList());



                            }catch (Exception ex) {
                                ex.printStackTrace();
                            }
                        }
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                        hideProgress();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });
    }

    private void FavPro() {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .saveProjectFocus(mInfo.getId(),userToken)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            super.onNext(json);
                            return;
                        }
                        ToastUtil.showShort("关注成功");
                        focusId = json.get("data").getAsJsonObject().get("focusId").getAsString();
                        FavreturnFlag = true;
                        supportInvalidateOptionsMenu();
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });
    }

    private void GetFavPro() {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .checkFocus(mInfo.getId(),userToken)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
//                            super.onNext(json);
                            return;
                        }
//                        ToastUtil.showShort("提交成功");

                         FavreturnFlag = json.get("data").getAsJsonObject().get("returnFlag").getAsBoolean();

                        if(FavreturnFlag)
                        {
                            focusId = json.get("data").getAsJsonObject().get("focusId").getAsString();
//                            menu_fav.setIcon(R.drawable.menu_right_fav_fouse);
                        }else{
                            focusId= "";
//                            menu_fav.setIcon(R.drawable.menu_right_fav);
                        }
                        supportInvalidateOptionsMenu();
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });
    }

    private void DelFavPro() {
        if(focusId == null || "".equalsIgnoreCase(focusId))
        {
            return;
        }
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .delProjectFocus(focusId,userToken)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            super.onNext(json);
                            return;
                        }
                        FavreturnFlag = false;
                        supportInvalidateOptionsMenu();
                        ToastUtil.showShort("取消成功");
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });
    }


}
